#include #include using namespace std; //-------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------fibonacci------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------- int febo (int x ){ if(x==0|| x==0) return 0; else if(x ==1|| x==1) return 1; else return febo(x-1)+febo(x-2); } int main() { int a; cin >> a; cout << febo(a); return 0; } //-------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------power------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------- // x is the number and y is the power like (x^y) // we will stop when y become 0 or we will reduce y by 1 /* long int power(int x, int y) { if (y == 0) return 1; else { return x * power(x, y - 1) ; } } int main() { cout << power( 2, 0); return 0; } */ //-------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------sum------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------- // when we pass an array to recursion function it has to be Gloal // here we have (i) will equal the max index in arr after we increase it in the loop // and we use it to access the arr elements /* int i; int arr[10] ; int sum(int ar[], int x ) { if (i == 0) return ar[0]; else return x + sum(ar, ar[--i]) ; } int main() { for (i = 0; i < 10; i++) cin >> arr[i]; cout< 1) return x * fact(x - 1); else return 1; } int main() { int x; cin >> x; cout << fact(x); } */ //------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------GCD------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------- // GCD: greatest common divisor is the largest positive integer that divides each of the 2 integers. //For example, the gcd of 8 and 12 is 4 /*int gcd(int x, int y) { if (x % y == 0) return y; else { int z; z = x % y; x = y; y = z; return gcd(x, y); } } int main() { int x, y; cin >> x >> y; cout << gcd(max(x, y), min(x, y)); return 0; } */